package com.ruoyi.qiushi.service.deviceData.impl;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.qiushi.mapper.deviceData.TblQsBloodPressureRecordMapper;
import com.ruoyi.qiushi.domain.deviceData.TblQsBloodPressureRecord;
import com.ruoyi.qiushi.service.deviceData.ITblQsBloodPressureRecordService;

/**
 * 血压数据源Service业务层处理
 *
 * @author ruoyi
 * @date 2024-01-10
 */
@Service
public class TblQsBloodPressureRecordServiceImpl implements ITblQsBloodPressureRecordService {
    @Autowired
    private TblQsBloodPressureRecordMapper tblQsBloodPressureRecordMapper;
    @Autowired
    private ISysConfigService configService;

    /**
     * 查询血压数据源
     *
     * @param id 血压数据源主键
     * @return 血压数据源
     */
    @Override
    public TblQsBloodPressureRecord selectTblQsBloodPressureRecordById(Long id) {
        return tblQsBloodPressureRecordMapper.selectTblQsBloodPressureRecordById(id);
    }

    /**
     * 查询血压数据源列表
     *
     * @param tblQsBloodPressureRecord 血压数据源
     * @return 血压数据源
     */
    @Override
    public List<TblQsBloodPressureRecord> selectTblQsBloodPressureRecordList(TblQsBloodPressureRecord tblQsBloodPressureRecord) {
        return tblQsBloodPressureRecordMapper.selectTblQsBloodPressureRecordList(tblQsBloodPressureRecord);
    }

    /**
     * 新增血压数据源
     *
     * @param tblQsBloodPressureRecord 血压数据源
     * @return 结果
     */
    @Override
    public int insertTblQsBloodPressureRecord(TblQsBloodPressureRecord tblQsBloodPressureRecord) {
        tblQsBloodPressureRecord.setCreateTime(DateUtils.getNowDate());
        return tblQsBloodPressureRecordMapper.insertTblQsBloodPressureRecord(tblQsBloodPressureRecord);
    }

    /**
     * 修改血压数据源
     *
     * @param tblQsBloodPressureRecord 血压数据源
     * @return 结果
     */
    @Override
    public int updateTblQsBloodPressureRecord(TblQsBloodPressureRecord tblQsBloodPressureRecord) {
        tblQsBloodPressureRecord.setUpdateTime(DateUtils.getNowDate());
        return tblQsBloodPressureRecordMapper.updateTblQsBloodPressureRecord(tblQsBloodPressureRecord);
    }

    /**
     * 批量删除血压数据源
     *
     * @param ids 需要删除的血压数据源主键
     * @return 结果
     */
    @Override
    public int deleteTblQsBloodPressureRecordByIds(Long[] ids) {
        return tblQsBloodPressureRecordMapper.deleteTblQsBloodPressureRecordByIds(ids);
    }

    /**
     * 删除血压数据源信息
     *
     * @param id 血压数据源主键
     * @return 结果
     */
    @Override
    public int deleteTblQsBloodPressureRecordById(Long id) {
        return tblQsBloodPressureRecordMapper.deleteTblQsBloodPressureRecordById(id);
    }

    /**
     * 获取数据
     *
     * @return
     */
    @Override
    @DataSource(value = DataSourceType.SLAVE)
    public List<TblQsBloodPressureRecord> getData(String startTime, String endTime) {
        List<TblQsBloodPressureRecord> tblQsBloodPressureRecords = tblQsBloodPressureRecordMapper.selectByCreateTime(startTime, endTime);
        return tblQsBloodPressureRecords;
    }


}
